package com.zzgele.qmzb.api.web;

import com.alibaba.boot.dubbo.annotation.DubboConsumer;
import com.zzgele.qmzb.api.core.Constants;
import com.zzgele.qmzb.api.core.Result;
import com.zzgele.qmzb.api.core.ResultGenerator;
import com.zzgele.qmzb.api.model.InitApp;
import com.zzgele.qmzb.api.service.ReportTypeService;
import com.zzgele.qmzb.api.service.RoomTypeService;
import com.zzgele.qmzb.api.service.SensitiveWordService;
import com.zzgele.qmzb.api.utils.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import redis.clients.jedis.JedisPool;

import javax.annotation.Resource;
import java.util.HashMap;

/**
* Created by Martin on 2017/07/09.
*/
@RestController
@RequestMapping("/init")
public class InitController {
    private final Logger logger = LoggerFactory.getLogger(getClass());
    @DubboConsumer
    private RoomTypeService roomTypeService;
    @DubboConsumer
    private ReportTypeService reportTypeService;
    @DubboConsumer
    private SensitiveWordService sensitiveWordService;

    @PostMapping("/app")
    public Result app(InitApp initApp) {
        //logger.info("{}", initApp);

        String version = initApp.getVersion();

        HashMap hashMap = new HashMap();
        hashMap.put("gift_version_new", "1.0");
        hashMap.put("gift_package_url", "");
        hashMap.put("ios_version_new", "1.0");
        hashMap.put("android_version_new", "1.0");
        hashMap.put("update_url", ""); //应用宝
        hashMap.put("cur_version_usable", Constants.SUCCESS);
        hashMap.put("system_time", DateUtil.getCurUnixTimeStampInt());
        hashMap.put("location_log_default", Constants.LOG_DEF);
        hashMap.put("location_lat_default", Constants.LAT_DEF);
        //红包
        hashMap.put("red_packet_limit_minute", Constants.RED_PACKET_LIMIT_MINUTE);
        hashMap.put("red_packet_limit_number", Constants.RED_PACKET_LIMIT_NUMBER);
        //手续费
        hashMap.put("tax", Constants.COMMISSION_CHARGE);
        //房间类型
        //List<HashMap> roomTypeList = roomTypeService.getList(null);
        //hashMap.put("room_type_list", roomTypeList);

        //举报类型
        //List<HashMap> reportTypeList = reportTypeService.getList(null);
        //hashMap.put("report_type_list", reportTypeList);

        //TODO:读缓存
        //聊天室公告
        hashMap.put("chatroom_announcement", "全民主播有义务保证健康有序的直播环境。全民主播对直播间中的连麦者、" +
                "房间信息等所有直播行为、直播内容负责。若有以上违规行为，全民官方将依据违规情况，连带处罚违规者及全民主播。" +
                "\n【欢迎宝宝体验全民直播！您现在使用的版本还是内测版呦，有些功能技术大大还在加班加点的完善中，我们随时欢迎各位宝宝提供宝贵意见。希望全民直播能与您共同成长，我们将会尽快完善、优化各个功能。据说，这个时候来到全民的都是真爱。】"+
                "\n【全民直播，致力于打造完美的视频直播服务，全心全意为全民宝宝创造最优的使用体验，祝您体验愉快】");
        //敏感词
        String sensitiveWords = "滚,傻逼,SB,去你妈的,鸡巴";
        hashMap.put("sensitive_words", sensitiveWords);
        //巡管accids
        String patrolAccids = "375f05e8402348af845a4a9367796f07,a6d0edee934a44be8f195ffccdea7ba2";
        hashMap.put("patrol_accids", patrolAccids);


        return ResultGenerator.genSuccessResult(hashMap);
    }
}
